package com.itheima.api.stream.demo01;

import java.util.ArrayList;

public class StreamFirstExperience {

    public static void main(String[] args) {

        ArrayList<String> list = new ArrayList<>();
        list.add("蓝湛");
        list.add("蓝忘机");
        list.add("蓝涣");
        list.add("蓝曦臣");
        list.add("魏婴");
        list.add("魏无羡");
        list.add("温宁");
        list.add("温琼林");
        list.add("蓝愿");
        list.add("蓝思追");

        ArrayList<String> list1 = new ArrayList<>();
        for (String s : list){
            if (s.startsWith("蓝")){
                list1.add(s);
            }
        }

        ArrayList<String> list2 = new ArrayList<>();
        list1.forEach(s -> {
            if (s.length() == 3){
                list2.add(s);
            }
        });

        list2.forEach(s -> System.out.println(s));
        System.out.println("------------------");

        list.stream().filter(s -> s.startsWith("蓝")).filter(s -> s.length() == 3).forEach(s -> System.out.println(s));
    }
}
